package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LhkHotelInfo;
import com.ruoyi.system.service.ILhkHotelInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店信息管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/system/info")
public class LhkHotelInfoController extends BaseController
{
    @Autowired
    private ILhkHotelInfoService lhkHotelInfoService;

    // 查询所有酒店信息 -- 用于前端下拉框
    @GetMapping("/all")
    public AjaxResult getAllHotels() {
        System.out.println("-------------");
        return success(lhkHotelInfoService.selectLhkHotelInfoList1());
    }
    /**
     * 查询酒店信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhkHotelInfo lhkHotelInfo)
    {
        //startPage();
        List<LhkHotelInfo> list = lhkHotelInfoService.selectLhkHotelInfoList(lhkHotelInfo);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:hotel_info:list')")
    @GetMapping("/lists")
    public TableDataInfo lists(Integer managerId)
    {
        startPage();
        List<LhkHotelInfo> list = lhkHotelInfoService.selectLhkHotelInfoList2(managerId);
        return getDataTable(list);
    }

    /**
     * 导出酒店信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:export')")
    @Log(title = "酒店信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhkHotelInfo lhkHotelInfo)
    {
        List<LhkHotelInfo> list = lhkHotelInfoService.selectLhkHotelInfoList(lhkHotelInfo);
        ExcelUtil<LhkHotelInfo> util = new ExcelUtil<LhkHotelInfo>(LhkHotelInfo.class);
        util.exportExcel(response, list, "酒店信息管理数据");
    }

    /**
     * 获取酒店信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:query')")
    @GetMapping(value = "/{hotelId}")
    public AjaxResult getInfo(@PathVariable("hotelId") Long hotelId)
    {
        return success(lhkHotelInfoService.selectLhkHotelInfoByHotelId(hotelId));
    }

    /**
     * 新增酒店信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:add')")
    @Log(title = "酒店信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhkHotelInfo lhkHotelInfo)
    {
        return toAjax(lhkHotelInfoService.insertLhkHotelInfo(lhkHotelInfo));
    }

    /**
     * 修改酒店信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:edit')")
    @Log(title = "酒店信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhkHotelInfo lhkHotelInfo)
    {
        return toAjax(lhkHotelInfoService.updateLhkHotelInfo(lhkHotelInfo));
    }

    /**
     * 删除酒店信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_info:remove')")
    @Log(title = "酒店信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotelIds}")
    public AjaxResult remove(@PathVariable Long[] hotelIds)
    {
        return toAjax(lhkHotelInfoService.deleteLhkHotelInfoByHotelIds(hotelIds));
    }
}
